package com.inno.subject.domain.strategy.ai;

import jakarta.annotation.Resource;
import org.springframework.beans.factory.InitializingBean;
import org.springframework.stereotype.Component;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @author shenzeyang
 */
@Component
public class InterviewHandlerFactory implements InitializingBean {

    @Resource
    private List<InterviewMockHandler> interviewMockHandlerList;
    // 还需要一个map
    private final Map<String, InterviewMockHandler> interviewMockHandlerMap = new HashMap<>();

    public InterviewMockHandler getInterviewHandler(String type) {
        return interviewMockHandlerMap.get(type);
    }

    @Override
    public void afterPropertiesSet() throws Exception {
        interviewMockHandlerList.forEach(interviewMockHandler -> interviewMockHandlerMap.put(interviewMockHandler.getType(), interviewMockHandler));
    }
}
